package com.sluggard.security.manage.model.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.sluggard.security.manage.model.entity.RoleEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
import java.util.Set;

@Setter
@Getter
public class SecurityUser extends User {

    @Schema(description = "用户id")
    private Long id;

    @Schema(description = "最后选择角色")
    private Long roleId;

    @Schema(description = "姓名")
    private String realName;

    @Schema(description = "密码")
    private String pass;

    @Schema(description = "昵称")
    private String nickName;

    @Schema(description = "类型{1:超级管理员,2:普通管理员}")
    private Boolean type;

    @Schema(description = "电子邮件")
    private String email;

    @Schema(description = "手机号码")
    private String mobileNo;

    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    @Schema(description = "最后修改时间")
    private LocalDateTime modifyTime;

    @Schema(description = "账户过期时间")
    private LocalDateTime expirationTime;

    @Schema(description = "状态{1:正常,2:停用}")
    private Boolean status;

    @Schema(description = "描述")
    private String descn;

    @Schema(description = "是否删除{0:正常,1:删除}")
    private Boolean deleted;

    @Schema(description = "版本号")
    private Integer version;

    @TableField(value = "roles")
    private List<RoleEntity> roles;

    @TableField(value = "resources")
    private Set<String> resources;

    public SecurityUser(String username, String password, Collection<? extends GrantedAuthority> authorities) {
        super(username, password, authorities);
    }

    public SecurityUser(String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities) {
        super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
    }
}
